package createThread.cn.tedu.threaddemo.test1.Anonymous.test2;

public class SleepTest1 {
    public static void main(String[] args){
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while(true){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
    }
    public static void testSleep(){
        new Thread(()->{
           while (true){
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               System.out.println("thread2");
           }
        });
    }
}
